import 'package:flutter/material.dart';
import 'package:emby/util/function.dart';

class TabItem extends StatelessWidget {
  TabItem({this.title, this.icon, this.selected, this.onTap, this.badge: 0});

  final bool selected;
  final String title;
  final String icon;
  final Function onTap;
  final int badge;
  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: GestureDetector(
        onTap: onTap,
        child: Stack(
          children: <Widget>[
            Container(
              color: Colors.white,
              padding: EdgeInsets.symmetric(vertical: 5),
              width: MediaQuery.of(context).size.width / 4,
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  SizedBox(
                    height: 30,
                    width: 30,
                    child: ImageIcon(
                      AssetImage("images/icons/$icon.png"),
                      color: selected ? Colors.blue : Colors.black26,
                      size: 30,
                    ),
                  ),
                  Text(
                    title,
                    style: TextStyle(color: selected ? Colors.blue : Colors.black26, fontSize: 12),
                  ),
                ],
              ),
            ),
            badge != null && badge > 0
                ? Container(
                    height: 20,
                    margin: EdgeInsets.only(left: 50, top: 5),
                    padding: EdgeInsets.symmetric(horizontal: 3.5),
                    decoration: BoxDecoration(
                      color: Colors.red,
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Text(
                      "$badge",
                      style: TextStyle(color: Colors.white, fontSize: 7.5),
                    ),
                  )
                : Container(
                    height: 10,
                  ),
          ],
        ),
      ),
    );
  }
}
